//1.导入axios对象
import axios from 'axios'

//2.创建axios对象create
const Server = axios.create({
    baseURL: '', //跟地址
    timeout: 3000, //超时时间
});
Server.interceptors.request.use(function (config) {
    // 获取本地存储中的token值
    let token = sessionStorage.getItem('03B_user');
    //token添加到header中Authorization属性中去
    config.headers['Authorization'] = token;
    return config
}, (error) => {
    return Promise.reject(error)
});
//4.相应拦截器
Server.interceptors.response.use((response) => {
    // console.log(response)
    if (response.status == 200) {
        return response.data
    }
}, (error) => {
    return Promise.reject(error)
});
//抛出拦截器
export default Server;